import { useUserStore } from '@/stores/user'

let unwatch = () => {}
export default {
  async mounted(el: HTMLElement, binding: any) {
    const userStore = useUserStore()
    const { value } = binding
    unwatch = watch(
      () => userStore.user,
      () => {
        if (userStore.user.id !== 0) {
          if (value > userStore.user.role.permission) {
            el.remove()
          }
        }
      }
    )
  },
  unmounted(el: HTMLElement) {
    unwatch()
  }
}
